package cn.me.alphamq.nameserver.enumeration;

/**
 * 复制消息类型的枚举类
 *
 * @author f
 */
public enum ReplicationMsgCodeEnum {
    INSERT_OR_UPDATE(1, "添加或更新数据"),
    DELETE(2, "删除数据");

    // 根据枚举的 code 属性获取枚举
    public static ReplicationMsgCodeEnum of(int code) {
        for (ReplicationMsgCodeEnum msgCode : ReplicationMsgCodeEnum.values()) {
            if (msgCode.code == code) {
                return msgCode;
            }
        }
        throw new RuntimeException("invalid replication msg code: " + code);
    }

    private final int code;
    private final String desc;

    ReplicationMsgCodeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

}
